package com.stenio.fancat.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.stenio.fancat.domain.Brand;
import com.stenio.fancat.form.BrandForm;
import com.stenio.fancat.service.BrandService;
import com.stenio.fancat.util.ResultUtil;
import com.stenio.fancat.vo.Result;

/**
 * 品牌模块controller
 * @author stenio
 */
@RestController
@RequestMapping("brand")
public class BrandController {

	@Autowired
	private BrandService brandService;

	/**
	 * 通过品牌名称查询品牌列表
	 * 
	 * @param brandName
	 * @return
	 */
	@PostMapping("query")
	@ResponseBody
	public Result queryBrand(@RequestBody BrandForm brandForm) {
		List<Brand> brands = brandService.queryBrandByLikeName(brandForm);
		return Result.success(brands);
	}

	/**
	 * 分页查询品牌列表
	 * 
	 * @param current
	 * @param size
	 * @return
	 */
	@PostMapping("brandList")
	@ResponseBody
	public Result queryBrandList(@RequestBody BrandForm brandForm) {
		return ResultUtil.success(brandService.queryBrandPage(brandForm));
	}

}
